﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BruTile.Web
{
    public class BaiduMapSource : ITileSource
    {
        public ITileProvider Provider { get; private set; }
        public ITileSchema Schema { get; private set; }
        public static string BaseUrl { get; private set; }

        public BaiduMapSource()
        {
            this.Schema = new BruTile.PreDefined.BaiduMapSchema();
            this.Provider = new WebTileProvider(RequestBuilder);
        }

        public BaiduMapSource(string baseUrl, ITileSchema schema)
        {
            BaseUrl = baseUrl;
            Provider = CreateProvider();
            Schema = schema;
        }

        private static ITileProvider CreateProvider()
        {
            return new WebTileProvider(RequestBuilder);
        }

        private static IRequest RequestBuilder
        {
            get
            {

                var requestUrl = "http://q3.baidu.com/it/u=x={1};y={2};z={0};type=web&fm=44";                
                return new BasicRequest(requestUrl);
               
            }
        }
    }
}
